<?php /* EL PSY CONGROO */    			 	 		
require '../../../../zb_system/function/c_system_base.php';    			 				
require '../../../../zb_system/function/c_system_admin.php';    	      	
$zbp->Load();    	 				  
$action='root';        	  	
if (!$zbp->CheckRights($action)) {$zbp->ShowError(6);die();}      	    	
if (!$zbp->CheckPlugin('San_Rabbit')) {$zbp->ShowError(48);die();}    	  	 		 
$blogtitle='主题配置';     			 	 	
require $blogpath . 'zb_system/admin/admin_header.php';    		 			  
require $blogpath . 'zb_system/admin/admin_top.php';    	 		    
require $blogpath . 'zb_users/theme/San_Rabbit/plugin/header.php';     			   	
if ($_POST && isset($_POST)) {     		   	 
	 if (function_exists('CheckIsRefererValid')) CheckIsRefererValid();    						 	
    if ($_GET && isset($_GET['type'])) {    	 					 
        if ($_GET['type'] == 'add') {    					 	 
            if($zbp->Config('San_Rabbit')->HasKey('homeSliderArray')){$homeSliderArray = json_decode($zbp->Config('San_Rabbit')->homeSliderArray,true);}      		 	 	
            $homeSliderArray[] = $_POST;      			 	 
            foreach ($homeSliderArray as $key => $row) {     		 	   
                $order[$key] = $row['order'];       				 
                $title[$key]  = $row['title'];     			 	 	
            }     		  	  
            array_multisort($order, SORT_ASC, $title, SORT_DESC, $homeSliderArray);      			   
            $zbp->Config('San_Rabbit')->homeSliderArray = json_encode($homeSliderArray);     			    
            $zbp->SaveConfig('San_Rabbit');    	   	   
        } elseif ($_GET['type'] == 'edit') {    		  		  
            $homeSliderArray = json_decode($zbp->Config('San_Rabbit')->homeSliderArray,true);     	 	 			
            $editid = $_POST['editid'];    	   		  
            unset($_POST['editid']);      					 
            $homeSliderArray[$editid] =$_POST;    				 			
            foreach ($homeSliderArray as $key => $row) {     					  
                $order[$key] = $row['order'];      		    
                $title[$key]  = $row['title'];      		    
            }     			   	
            array_multisort($order, SORT_ASC, $title, SORT_DESC, $homeSliderArray);    	  		 	 
            $zbp->Config('San_Rabbit')->homeSliderArray = json_encode($homeSliderArray);    			 		  
            $zbp->SaveConfig('San_Rabbit');    		    		
        }     	 	    
    }    		    	 
} elseif ($_GET && isset($_GET)) {    		 		 		
    if ($_GET['type'] == 'del') {     		  	 	
        $homeSliderArray = json_decode($zbp->Config('San_Rabbit')->homeSliderArray,true);    		 	   	
        $editid = $_GET['id'];      	   		
        unset($homeSliderArray[$editid]);     					 	
        $zbp->Config('San_Rabbit')->homeSliderArray = json_encode($homeSliderArray);    		  	  	
        $zbp->SaveConfig('San_Rabbit');      	 			 
    }    					   
}      			  	
if($zbp->Config('San_Rabbit')->HasKey('homeSliderArray')){       	    
    $homeSliderArray = json_decode($zbp->Config('San_Rabbit')->homeSliderArray,true);      		 	  
}else{    	 					 
    $homeSliderArray = array();    			 	 	 
}       	 	  
?>
<style>
.uplod_img {width:70%;}
.uploadimg strong {margin-top: 3px;cursor:pointer; background:#3A6EA5; width:30%; text-align:center; padding:1px 0; color:#fff; display:block; float:right;}
.uploadimg img {width:15%; height:auto; float:left; display:inline-block; margin-right:5%;}
.uploadimg input {float:left;}
input.sedit{ width:93%;}
table input{margin:0.25em 0;}
table input.text{padding: 2px 5px;}
table .button{padding: 2px 12px 5px 12px; margin: 0.25em 0;}
</style>
<div class="page">
    <div class="left-admin-menu">
        <nav class="admin-menu">
          <ul id="treeMenu" class="tree tree-menu" data-ride="tree">
            <?php San_Rabbit_SubMenu(1);?>
            
          </ul>
        </nav>
    </div>
    <div class="content">
        <div class="panel">
            <div class="panel-heading">
                <strong><i class="icon icon-sliders"></i>&nbsp;&nbsp;幻灯片设置</strong>
            </div>
            <div class="table-border">
                <table width="100%" border="1" class="tableBorder">
                    <tr>
                        <th scope="col" width="5%" height="32" nowrap="nowrap">序号</th>
                        <th scope="col" width="20%">标题</th>
                        <th scope="col" width="35%">图片</th>
                        <th scope="col" width="20%">链接</th>
                        <th scope="col" width="5%">排序</th>
                        <th scope="col" width="10%">操作</th>
                    </tr>
                    <form action="?type=add" method="post">
                        <tr>
                            <td align="center"></td>
                            <td><input type="text" class="sedit" name="title" value=""></td>
                            <td><div class="uploadimg"><input type="text" class="uplod_img" name="img" value=""><input type="button" class="btn upload_button btn-primary" value="上传" style="margin-top: 1px!important"></div></td>
                            <td><input type="text" class="sedit" name="url" value=""></td>
                            <td><input type="text" name="order" value="" style="width:40px"></td>
							<input type="hidden" name="csrfToken" value="<?php echo $zbp->GetCSRFToken(); ?>">
                            <td><input type="submit" class="button" value="增加"/></td>
                        </tr>
                    </form>
<?php
foreach ($homeSliderArray as $key => $value) {     			 	 	
    echo <<<eof
    <form action="?type=edit" method="post">
    <tr>
<td align="center">{$key}</td>
<input type="hidden" name="editid" value="{$key}">
<td><input type="text" class="sedit" name="title" value="{$value['title']}" ></td>
<td><div class="uploadimg"><img src="{$value['img']}"/><input type="text" class="uplod_img" name="img" value="{$value['img']}" ></div></td>
<td><input type="text" class="sedit" name="url" value="{$value['url']}" ></td>
<td><input type="text" class="sedit" name="order" value="{$value['order']}" style="width:40px"></td>
<td nowrap="nowrap">
<input type="hidden" name="csrfToken" value="{$zbp->GetCSRFToken()}">
<input type="submit" class="button" value="修改"/>
<input type="button" class="button" value="删除" onclick="if(confirm('您确定要进行删除操作吗？')){location.href='?type=del&id={$key}'}"/></td></tr></form>
eof;
}    		     	
?>
</table>
                    </div>
                </div>
                
                

            </div>
        <div class="copyright">
            <p>三十工作室</p>
        </div>
		
	</div>	

<?php
     		 		  
require $blogpath . 'zb_system/admin/admin_footer.php';     	  				
RunTime();      	 				
?>